-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
400 returning when calling elasticsearch from feign #424
Comments
maybe do a curl -v? also, if it doesn't look obvious, you could use
wireshark or something to get exactly what went on the wire from feign (ex
this would show a Host header value)
|
So this is what I got with the
I tried using wire shark to view the url but unfortunately I suck at wireshark. I can see the packets (SYN, ACK, FIN) but I can't determine the url past When I have
So at this point I already have the correct url. But with
So what is happening is that feign is not injecting the the variable (in this case it turns into Any idea? |
Any word on this? |
sorry.. off radar as in conference right now.
|
:( |
ok looking at your dump, it looks like a request body is being created, eventhough this is a GET request! This sounds very strange to me. |
ex the below is showing a json body being made. The code you pasted doesn't seem like it should be creating a json body. Is there anything else (perhaps about how feign is constructed), which might explain this?
|
This is what I have:
Creating it in another class.
Then calling it like this:
|
No obvious problem. I will have a look and get back by tomorrow
|
Thanks for the help!! |
This is a bug for sure. Not sure yet which of the various recent changes caused it. interface Issue424 {
@RequestLine("GET /_search?q=body:{body}")
String get(@Param("body") String body);
}
@Test
public void getDoesntImplyFormParams() throws Exception {
List<MethodMetadata> mds = contract.parseAndValidatateMetadata(Issue424.class);
assertThat(mds.get(0).formParams()).isEmpty();
} |
actually, I see what's going on. We added support for partial-match on headers, and not on queries. Ex. the |
This is to help develop apis like Elasticsearch which nest queries in query parameters. Fixes #424
This is great thank you |
This is to help develop apis like Elasticsearch which nest queries in query parameters. Fixes #424
Sure sorry about the delay
|
Sorry for the super late response. I was away of vacation. But I am still getting the same issue
|
that doesn't look like almost works :) it looks like "doesn't work at all"!
sure you are on latest feign, right?
|
Lol I edited my response. I thought It was different then before. https://mvnrepository.com/artifact/com.netflix.feign/feign-core/8.18.0 I can even go to the line with the edits. So yes. |
latest has the fix:
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-core</artifactId>
<version>9.1.0</version>
</dependency>
|
Yeah I tried this too:
|
So the actual log with 9.1.0 is:
There is no { "jay" } |
sheesh I think you're right. there is another place we need to change.
|
Failing test: @Test
public void resolveTemplateWithParameterizedSubstringQueryValue() {
RequestTemplate template = new RequestTemplate().method("GET")
.append("_search").query("q", "body:{body}");
template.resolve(mapOf("body", "text"));
assertThat(template)
.hasQueries(entry("q", asList("body:text")));
} |
@jaylucas might be a couple days to fix.. here's a workaround that would work if you have only one input to the "q" parameter: @RequestLine("GET /_search?q={q}")
public ElasticGetResponse getResumes(@Param(value = "q", expander = PrefixBodyExpander.class) String body);
static final class PrefixBodyExpander implements Param.Expander {
@Override
public String expand(Object value) {
return "body:" + value;
}
} |
Yeah I figured. Thanks for the update. I actually have been doing that while this issue is being resolved. The problem with that is when dealing with ids. let say:
This searches all occurrences of 1 which can be many more times then the unique id im looking for
Grabs the 1 value Im looking for |
id:1 would still work with the janky workaround :) Anyway glad you have a workaround.. should have this sorted in a few days.
|
Thank you 👍 |
Is this sorted yet? I am unable to run my client like: I run into NPE at Caused by: java.lang.NullPointerException: null I am on spring-cloud-starter-feign 1.3.2.RELEASE(feign-core 9.5.0) |
ignore my query, i was passing incorrectly, sorry! |
Any new on that? I try calling an API with a request looking like ".../test?param=value={v}" but the "{v}" is not replaced (using version 9.5.1).
|
@slepasteur @RequestLine ("GET /test?param=&value={v}")
void test(@Param ("v") String v); Second, this issue should be fixed for most cases outlined. I'm going to close this issue. Please create a new issue, including a test case if you can, if you continue to have trouble. |
So I have a basic request to a locally running instance of elasticsearch
Here is what I get through the logger:
Now of course I dont get the problem when I
curl
the same endpointreturns the correct docs
My question is why does feign hate that colon? When I have
_search?q=phil
it works....The text was updated successfully, but these errors were encountered: